package com.shelpe.services.sinbad.entity.mongo;

import java.util.Date;
import java.util.List;

import javax.persistence.Id;

import org.apache.commons.lang3.time.DateFormatUtils;
import org.springframework.data.mongodb.core.index.Indexed;
import org.springframework.data.mongodb.core.mapping.Document;

import com.shelpe.services.sinbad.controller.KeywordsController;
import com.shelpe.services.sinbad.entity.jpa.Adgroup;
import com.shelpe.services.sinbad.model.Keyword;

import lombok.Data;

@Data
@Document(collection="keyword_supplement_logs")
public class KeywordSupplementLog {

	@Id
	private String id;
	@Indexed
	private long adgroupID;
	private Adgroup adgroup;
	private Date executeTime;
	
	private List<KeywordsController.PricingKeyword> supplements;
	private List<Keyword> results;
	
	public void from(Adgroup adgroup){
		this.adgroupID = adgroup.getAutoID();
		this.adgroup = adgroup;
		this.executeTime = new Date();
		this.id = DateFormatUtils.format(this.executeTime, "yyyyMMddhhmmss") + "_" + this.adgroupID;
	}
}
